/**
 * 
 */
package group.anglers.om.core.persistence.serialization.impl;

import group.anglers.om.core.persistence.serialization.Column;

import java.util.ArrayList;
import java.util.List;

/**
 * @author an.pham
 *
 */
public class ModelSerializationImpl implements ModelSerialization {
	private List<Column> columns;
	private Object primaryKey;
	private String tableMapping;
	private Class<?> modelClass;
	
	@Override
	public List<Column> getColumns() {
		return columns;
	}

	@Override
	public String getTableName() {
		return tableMapping;
	}

	@Override
	public boolean hasTableMapping() {
		return (tableMapping != null);
	}
	
	@Override
	public Object getPrimaryKey() {
		return primaryKey;
	}
	
	@Override
	public Class<?> getModelClass() {
		return modelClass;
	}
	
	protected void addColumn(String name, Class<?> type ){
		if(columns == null){
			columns = new ArrayList<Column>();
		}
		
		columns.add(new ColumnImpl(name, type));
	}

	protected void setTableMapping(String tableMapping){
		this.tableMapping = tableMapping;
	}

	protected void setPrimaryKey(Object primaryKey) {
		this.primaryKey = primaryKey;
	}

	public void setModelClass(Class<?> modelClass) {
		this.modelClass = modelClass;
	}

}
